﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;

namespace ZF.WS.Person.expert
{
    public partial class CBand : ZF.BLL.Page.GMPage
    {
        [PageArgument(Key = "ti",DefaultValue=null)]
        public string title { get; set; }
        [PageArgument(Key = "t", DefaultValue = 0)]
        public int Type { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
               
                    Edit();
            }
        }
    
        public void Edit()
        {
            using (var dc = BLL.SiteInfo.CreateDBDataContext())
            {

                var USMember = dc.US_Member.FirstOrDefault(p => p.MemberId == CurrentUser.MemberId);
                if (USMember == null)
                    throw WarnFactory.CreateWarn(WarnCode.ReocrdNoFind);
                if(this.Type==0)
                    this.fckInfo.Value = USMember.CBank;
                else if(this.Type==1)
                    this.fckInfo.Value = USMember.DKType;
            }
        }
        public void EditSubmit(object sender, EventArgs e)
        {

            using (var ts = new System.Transactions.TransactionScope())
            {
                using (var dc = BLL.SiteInfo.CreateDBDataContext())
                {
                    var USMember = dc.US_Member.FirstOrDefault(p => p.MemberId == CurrentUser.MemberId);
                    if (USMember == null)
                        throw WarnFactory.CreateWarn(WarnCode.ReocrdNoFind);
                    if (this.Type == 0)
                        USMember.CBank = this.fckInfo.Value;
                    else if (this.Type == 1)
                        USMember.DKType = this.fckInfo.Value;
                   
                    SiteInfo.CheckFilterWords(this.fckInfo.Value);
                    try
                    {
                       
                        dc.SubmitChanges();
                        ts.Complete();
                    }
                    catch (Exception ex)
                    {
                        throw WarnFactory.CreateWarn(ex);
                    }
                    WarnFactory.CreateWarn(new PageWarnParameter()
                    {
                        JscriptMode = true,
                        Link = WarnLink.Current,
                        Message = "操作成功",
                    }).Alert();
                     

                }


            }

        }
    }
}
